package com.tfswue.springboot_demo02.controller;

import com.tfswue.springboot_demo02.service.EvenPublisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
// localhost:8080/user/register
@RequestMapping("/user")
public class RegisterController {
    @Autowired
    private EvenPublisherService evenPublisher;

    @RequestMapping("/register")
    public ResponseEntity<String> registerUser(
            @RequestParam String username,
            @RequestParam String email) {

        //业务处理...
        //发布用户注册事件
        evenPublisher.publishUserRegisterEvent(username, email);

        return ResponseEntity.ok("注册成功");
    }
}
